<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="css/mui.min.css">
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="css/app.css" />
		<link href="css/my.css" rel="stylesheet" />
		<style>
			.title {
				margin: 20px 15px 10px;
				color: #6d6d72;
				font-size: 15px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav bc2">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">意见反馈</h1>
		</header>
		<div class="mui-content bc">
			<div class="mui-card bc2">
				<div class="mui-card-content">
					<textarea id="content" style="width: 100%;min-height: 18.75rem;"></textarea>
					<button id="sub" type="button" class="mui-btn mui-btn-danger" style="width: 100%;">提交</button>
				</div>
			</div>
		</div>

	</body>
	<script src="js/mui.min.js"></script>
	<script src="js/config.js"></script>
	<script src="js/date.js"></script>
	<script src="js/book.js"></script>
	<script>
		var self;
		var deviceNum;
		var bookId;
		var content;
		mui.init();
		mui.plusReady(function() {
			self = plus.webview.currentWebview();
			bookId = self.bookId;
			content = self.content;
			if(!content){
				content = "";
			}
			deviceNum = plus.storage.getItem("deviceNum");
			if (deviceNum == null || deviceNum == "") {
				mui.toast('获取设备号失败，请确认是否开启权限', {
					duration: 'short',
					type: 'div'
				})
				return;
			}
			if (content != "") {
				document.getElementById("content").innerText = content;
			}
		});

		document.getElementById("sub").addEventListener('tap', function() {
			content = document.getElementById("content").value;
			if (content == "") {
				mui.toast('请填写反馈内容', {
					duration: 'short',
					type: 'div'
				})
				return;
			}
			document.getElementById("sub").setAttribute("disabled", "disabled");
			document.getElementById("sub").setAttribute("class", "mui-btn");
			mui.ajax(config.config.path + "/feedback", {
				data: {
					"bookId": bookId,
					"content": content,
					"deviceNum": deviceNum
				},
				dataType: 'json', //服务器返回json格式数据
				type: 'POST', //HTTP请求类型
				contentType: 'application/json;charset=utf-8',
				success: function(data) {
					mui.toast('提交成功', {
						duration: 'short',
						type: 'div'
					})
				}
			});
		});
	</script>
</html>
